Computer آرشيو وبلاگ نويسندگان چهار شنبه 29 آذر 1391برچسب:سی شارپ,آموزش,ویژوال استودیو,C#,Visual studio,learning, :: 18:25 :: نويسنده : مصطفی
آراﻳﻪ ھﺎ در ﺳﻲ ﺷﺎرپ : ;[]int[] table; // not int table
int[] numbers; // declare numbers as an int array of any size
numbers = new int[۱۰]; // numbers is a ۱۰-element array numbers = new int[۲۰]; // now it's a ۲۰-element array
String[] strData = new string[۲];
ﺗﻌﺮﻳﻒ و ﻣﻘﺪار دھﻲ اوﻟﯿﻪ string [] strData = { "۱۲۳۴","abcd" };
روﺷﻲ دﻳﮕﺮ ﺑﺮای ﻣﻘﺪار دھﻲ اوﻟﯿﻪ strData[۰] = "۱۲۳۴";
strData[۱] = "abcd";
ﺑﮕﺬارﻳﺪ. در اﻳﻦ ﻣﺜﺎل ﻣﻲ ﺧﻮاھﯿﻢex۰۶ ﺳﻲ ﺷﺎرپ را ﺑﺎز ﻛﻨﯿﺪ و ﻧﺎم آﻧﺮا در اﺑﺘﺪاConsole ﻣﺜﺎل : ﻳﻚ ﭘﺮوژه ی ﺟﺪﻳﺪ
: ﻧﺤﻮه ی ﻛﺎر ﺑﺎ آراﻳﻪ ھﺎ را ﻣﺮور ﻛﻨﯿﻢ
using System;
namespace ex۰۶ { class Class۱ { [STAThread] static void Main(string[] args) { string[] sGoalList = new string[۳]; string sReplyStatement = "You have choosen Goal '"; // Store goals in the array sGoalList[۰] = "Hike the Appalachian Trail"; sGoalList[۱] = "Run the marathon"; sGoalList[۲] = "Give $۱ million to worthwhile causes"; // Store response to goals in the array //(declaring and initializing on same line) string[] sGoalResponse = { "If you are staring from GA, you should get " + "started in early spring, so you will "+ "not get caught in snow.", "Make sure that you have a good pair of shoes.", "Start saving as soon as possible."}; // Give the user a list of goals to choose from Console.WriteLine("GOAL LIST"); for(int i = ۰; i < sGoalList.Length; i++) { Console.WriteLine("Goal " + i + " - " + sGoalList[i]); } .// Request the user to choose a goal Console.WriteLine (""); // Write an empty line for space " Console.Write("Please choose the number of the ;(" :[۲,۱,۰] + "goal that you want to achieve ;()Console.ReadLine { { {
منبع: سایت VCsharp.ir نظرات شما عزیزان: پيوندها
تبادل
لینک هوشمند
|
|||||||||||||||||
|